package com.lelefly.base.utils;

public class RandomUTils {
	
	public synchronized static String fix(String string,int length) {
		if (string.length()>=length) {
			return string;
		}else {
			for (int i = 0; i < length -string.length(); i++) {
				string = new StringBuffer(string).append("0").toString();
			}
		}
		return string;
	}

	/**
	 * 随机生成length长度的数
	 * @param length
	 * @return
	 */
	public synchronized static String random(int length){
		String string = ((int)(Math.random() * Math.pow(10, length))) + "";
		if (string.length()>=length) {
			return string;
		}else {
			for (int i = 0; i < length -string.length(); i++) {
				string = new StringBuffer(string).append("0").toString();
			}
		}
		return string;
	}
}
